﻿<!DOCTYPE HTML>
<html>
<head>
	<#_meta title="用户管理" type="default" />
</head>
<body>
<#_head/>
<#_menu/>
<section class="Hui-article-box">
	<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 权限管理 <span class="c-gray en">&gt;</span> 用户管理 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
	<div class="Hui-article">
		<article class="cl pd-20">
			<div class="cl pd-5 bg-1 bk-gray">
				<span class="l">
				</span>
			</div>
			<div class="mt-10">
				<table id="data_table" class="table table-border table-bordered table-hover table-bg"></table>
			</div>
		</article>
	</div>
</section>
<#_footer type="common,table"/>
<script type="text/javascript">
    $(document).ready( function () {
        var table =  $('#data_table').DataTable({
            pageLength:10,
            info : true, //显示表格左下角信息
            ordering: false,//关闭表格默认排序
            paging: true, //分页
            processing:true, //设置为true,就会有表格加载时的提示
            searching: false, //关闭本地搜索
            serverSide: true,//如果是服务器方式，必须要设置为true
            //使用ajax异步请求
            ajax:{
                dataSrc: function (json) {
                    json.draw = json.data.draw;
                    json.recordsTotal = json.data.recordsTotal;
                    json.recordsFiltered = json.data.recordsFiltered;
                    return json.data.data;
                },
                url:'/mgr/list',
                type:'post'
            },
            columns: [
                { data: null,title: "<input type='checkbox' name='checklist' id='checkall' class='checkall'/>",
                    render: function(data, type, row, meta) {return '<input id="checkchild" type="checkbox"  class="checkchild" value="' + row.suidCode + '" />'}
                },
                {data:"index",title:"序号",
                    render:function(data,type,row,meta){var startIndex = meta.settings._iDisplayStart;return startIndex+meta.row+1}
                },
                { data: 'id' ,title:"id"},
                { data: 'account' ,title:"账号"},
                { data: 'name' ,title:"姓名"},
                { data: 'sexName' ,title:"性别"},
                { data: 'roleName' ,title:"角色"},
                { data: 'deptName' ,title:"部门"},
                { data: 'email' ,title:"邮箱"},
                { data: 'phone' ,title:"电话"},
                { data: 'createtime' ,title:"创建时间"},
                { data: 'statusName' ,title:"状态"}
            ]
        });
    } );
    //添加用户
    function add() {
        layer_show("添加用户","/sysUser/add-page");
    }
    //删除用户
    function del(){
        //判断选择的条数是不是只有一条
        var arrays = checkedValue("checkchild");
        if (lyyApplication.util.isEmpty(arrays)){
            layer.alert("请选择要删除的记录");
            return false;
        }
        if (arrays.length>1){
            layer.alert("只能选择一条记录删除");
            return false;
        }
        layer.confirm("确认删除用户？", function(){
            $.post("/sysUser/del",{suidCode:arrays[0]},function (result) {
                if (result){
                    if (result['status']===0){
                        layer.confirm(result['msg'], function(){
                            window.location.reload();
                        });

                    }else {
                        layer.alert(result['msg']);
                    }
                }else {
                    layer.alert('系统异常');
                }
            })
        });

    }
    //修改用户
    function update() {
        //判断选择的条数是不是只有一条
        var arrays = checkedValue("checkchild");
        if (lyyApplication.util.isEmpty(arrays)){
            layer.alert("请选择要修改的记录");
            return false;
        }
        if (arrays.length>1){
            layer.alert("只能选择一条记录修改");
            return false;
        }
        layer_show("修改用户","/sysUser/update-page?suidCode="+arrays[0]);
    }

</script>
</body>
</html>